 
package com.junitUtil.aspect;	
import java.lang.reflect.Field;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.runtime.reflect.FieldSignatureImpl;

import com.junitUtil.spring.BeanCreatUtils;
import com.junitUtil.spring.DecoratorBeanFactory;





/**
 * aop处理代码
 * 
 **/
@Aspect
public class MyAspect   {
    public static DecoratorBeanFactory beanFactory= DecoratorBeanFactory.getInstance();
   
      public static void checkEntity(JoinPoint joinPoint ) {
           FieldSignatureImpl signature=(FieldSignatureImpl)joinPoint.getSignature() ;
          try {
            Field field = signature.getField();
  //          System.out.println("进入切面"+field.getName());
            signature.getField().setAccessible(true);
            Object tem=field.get(joinPoint.getTarget());
            if(tem!=null){
                 return ;
            }
             Object obj=null;
            obj = BeanCreatUtils.getBean(field.getType(), beanFactory, true);
            obj=beanFactory.getBean(field.getType());
            signature.getField().set(joinPoint.getTarget(), obj);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
     
 
      
}

